<?php
global $wpdb;
global $hfr_db_version;

delete_option("hfr_db_version");
add_option("hfr_db_version", $hfr_db_version);

require_once(ABSPATH . '/wp-admin/includes/upgrade.php');

$sql = 
"
CREATE TABLE IF NOT EXISTS `".$wpdb->prefix."hfr_url_craw` (
  `id` varchar(255) NOT NULL,
  `sitemap` varchar(255) NOT NULL,
  `userBlog` varchar(255) NOT NULL,
  `blog` varchar(255) NOT NULL,
  `reglink` varchar(255) NOT NULL,
  `type` varchar(255) NOT NULL,
  `domain` varchar(255) NOT NULL,
  `tag` varchar(255) NOT NULL,
  `linkSelecterJs` text NOT NULL,
  `activeLinkJs` varchar(255) NOT NULL default 'no',
  `linkSelecter` varchar(255) NOT NULL,
  `titleSelecter` varchar(255) NOT NULL,
  `contentSelecter` varchar(255) NOT NULL,
  `removeSelecter` varchar(255) NOT NULL,
  `customSelecter` text NOT NULL,
  `category` varchar(255) NOT NULL,
  `typelink` varchar(255) NOT NULL,
  `source` varchar(255) NOT NULL,
  `sourcetype` varchar(255) NOT NULL,
  `source_image` varchar(255) NOT NULL,
  `remove_tag_a` varchar(255) NOT NULL,
  `activeContentJs` varchar(255) NOT NULL default 'no',
  `md5` varchar(255) NOT NULL default 'no',
  `timeCraw` int(11) NOT NULL default '72',
  `error` int(11) NOT NULL default '0',
  `typeError` varchar(255) NOT NULL default 'No Error',
  `timeError` float NOT NULL,
  `time` float NOT NULL,
  `active` int(11) NOT NULL default '1',
  `field` varchar(255) NOT NULL,
  `order` int(11) NOT NULL default '0',
  `share` varchar(255) NOT NULL default 'yes',
  `craw` varchar(255) NOT NULL default 'yes',
  `getAll` varchar(255) NOT NULL default 'no',
  `arrLink` varchar(255) NOT NULL,
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
dbDelta($sql);


$sql = 
"
CREATE TABLE IF NOT EXISTS `".$wpdb->prefix."hfr_payment` (
  `id` varchar(32) NOT NULL,
  `customer` varchar(32) NOT NULL,
  `price` int(11) NOT NULL,
  `content` text NOT NULL,
  `created` datetime NOT NULL,
  `start` datetime NOT NULL,
  `end` datetime NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
";
dbDelta($sql);